// Copyright 2022 AndeyaLee. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package core

// Framework constants
const (

	// Default values
	DefaultAppName    = "faygo"
	DefaultAppVersion = "1.0"
	DefaultPort       = "8080"
	DefaultHost       = "0.0.0.0"

	// Timeout constants
	DefaultReadTimeout    = 0  // No timeout
	DefaultWriteTimeout   = 0  // No timeout
	DefaultRequestTimeout = 30 // 30 seconds

	// Memory constants
	DefaultMultipartMaxMemory = 32 // 32MB
	DefaultCacheSize          = 32 // 32MB

	// Session constants
	DefaultSessionName     = "faygosessionID"
	DefaultSessionProvider = "memory"
	DefaultSessionGCLife   = 300  // 5 minutes
	DefaultSessionMaxLife  = 3600 // 1 hour

	// API Doc constants
	DefaultAPIDocPath = "/apidoc"

	// XSRF constants
	DefaultXSRFKey    = "faygoxsrf"
	DefaultXSRFExpire = 3600 // 1 hour

	// Pool sizes
	DefaultContextPoolSize    = 100
	DefaultBufferPoolSize     = 100
	DefaultPathParamsPoolSize = 100
	DefaultHandlerPoolSize    = 100
	DefaultStringPoolSize     = 100
	DefaultMapPoolSize        = 100
)

// HTTP status codes
const (
	StatusOK                           = 200
	StatusCreated                      = 201
	StatusAccepted                     = 202
	StatusNoContent                    = 204
	StatusMovedPermanently             = 301
	StatusFound                        = 302
	StatusSeeOther                     = 303
	StatusNotModified                  = 304
	StatusTemporaryRedirect            = 307
	StatusPermanentRedirect            = 308
	StatusBadRequest                   = 400
	StatusUnauthorized                 = 401
	StatusForbidden                    = 403
	StatusNotFound                     = 404
	StatusMethodNotAllowed             = 405
	StatusNotAcceptable                = 406
	StatusConflict                     = 409
	StatusGone                         = 410
	StatusLengthRequired               = 411
	StatusPreconditionFailed           = 412
	StatusRequestEntityTooLarge        = 413
	StatusRequestURITooLong            = 414
	StatusUnsupportedMediaType         = 415
	StatusRequestedRangeNotSatisfiable = 416
	StatusExpectationFailed            = 417
	StatusTeapot                       = 418
	StatusTooManyRequests              = 429
	StatusInternalServerError          = 500
	StatusNotImplemented               = 501
	StatusBadGateway                   = 502
	StatusServiceUnavailable           = 503
	StatusGatewayTimeout               = 504
	StatusHTTPVersionNotSupported      = 505
)

// Content types
const (
	ContentTypeJSON       = "application/json"
	ContentTypeXML        = "application/xml"
	ContentTypeHTML       = "text/html"
	ContentTypePlain      = "text/plain"
	ContentTypeForm       = "application/x-www-form-urlencoded"
	ContentTypeMultipart  = "multipart/form-data"
	ContentTypeStream     = "application/octet-stream"
	ContentTypeJavaScript = "application/javascript"
	ContentTypeCSS        = "text/css"
	ContentTypeMarkdown   = "text/markdown"
)

// HTTP methods
const (
	MethodGET     = "GET"
	MethodPOST    = "POST"
	MethodPUT     = "PUT"
	MethodDELETE  = "DELETE"
	MethodPATCH   = "PATCH"
	MethodHEAD    = "HEAD"
	MethodOPTIONS = "OPTIONS"
	MethodCONNECT = "CONNECT"
	MethodTRACE   = "TRACE"
)

// Network types
const (
	NetTypeHTTP            = "http"
	NetTypeHTTPS           = "https"
	NetTypeUnixHTTP        = "unix_http"
	NetTypeUnixHTTPS       = "unix_https"
	NetTypeLetsEncrypt     = "letsencrypt"
	NetTypeUnixLetsEncrypt = "unix_letsencrypt"
)

// Session providers
const (
	SessionProviderMemory    = "memory"
	SessionProviderFile      = "file"
	SessionProviderRedis     = "redis"
	SessionProviderMySQL     = "mysql"
	SessionProviderPostgres  = "postgres"
	SessionProviderCouchbase = "couchbase"
	SessionProviderLedis     = "ledis"
	SessionProviderSSDB      = "ssdb"
	SessionProviderMemcache  = "memcache"
)

// Log levels
const (
	LogLevelCritical = "critical"
	LogLevelError    = "error"
	LogLevelWarning  = "warning"
	LogLevelNotice   = "notice"
	LogLevelInfo     = "info"
	LogLevelDebug    = "debug"
)

// Cache levels
const (
	CacheLevelNone   = "none"
	CacheLevelMemory = "memory"
	CacheLevelFile   = "file"
	CacheLevelRedis  = "redis"
)

// Compression levels
const (
	CompressionLevelNone    = 0
	CompressionLevelFast    = 1
	CompressionLevelBest    = 9
	CompressionLevelDefault = 6
)

// Validation tags
const (
	TagParam    = "param"
	TagRequired = "required"
	TagNonZero  = "nonzero"
	TagRange    = "range"
	TagLength   = "len"
	TagRegexp   = "regexp"
	TagMaxMB    = "maxmb"
	TagError    = "err"
	TagDesc     = "desc"
	TagName     = "name"
)

// Parameter positions
const (
	ParamInPath     = "path"
	ParamInQuery    = "query"
	ParamInFormData = "formData"
	ParamInBody     = "body"
	ParamInHeader   = "header"
	ParamInCookie   = "cookie"
)

// Node types
const (
	NodeTypeStatic = iota
	NodeTypeRoot
	NodeTypeParam
	NodeTypeCatchAll
)

// Error messages
const (
	ErrMsgInvalidPath      = "invalid path configuration"
	ErrMsgDuplicateRoute   = "duplicate route registration"
	ErrMsgInvalidWildcard  = "invalid wildcard configuration"
	ErrMsgInvalidNodeType  = "invalid node type"
	ErrMsgInvalidConfig    = "invalid configuration"
	ErrMsgSessionError     = "session error"
	ErrMsgDatabaseError    = "database error"
	ErrMsgValidationError  = "validation error"
	ErrMsgInternalError    = "internal server error"
	ErrMsgNotFound         = "not found"
	ErrMsgMethodNotAllowed = "method not allowed"
	ErrMsgUnauthorized     = "unauthorized"
	ErrMsgForbidden        = "forbidden"
	ErrMsgBadRequest       = "bad request"
	ErrMsgTimeout          = "request timeout"
	ErrMsgTooManyRequests  = "too many requests"
)

// Banner
const (
	Banner = `
        ___                    
      /  _/                    
     _| |_  __        __   ___ 
    /_   // _ |/\  /\/ _ \/ _ \
      | |  \/ /\ \/ / |/ / |/ /
      / / \_/\\ \  / \_ / \__/ 
     / /        / /  _\ \      
    \_/        \_/  \_\_/   VERSION ` + VERSION + "  URL https://gitcode.com/xiayang/faygo\n"
)
